import http from '@/utils/http'

const BASE_URL = '/vending/software'

export interface SoftwareResp {
  id: string
  softwareName: string
  versionName: string
  versionCode: string
  url: string
  description: string
  softwareType: string
  status: 0 | 1
  createUser: string
  createTime: string
  updateUser: string
  updateTime: string
  createUserString: string
  updateUserString: string
}
export interface SoftwareDetailResp {
  id: string
  softwareName: string
  versionName: string
  versionCode: string
  url: string
  description: string
  softwareType: string
  status: 0 | 1
  createUser: string
  createTime: string
  updateUser: string
  updateTime: string
  createUserString: string
  updateUserString: string
}
export interface SoftwareQuery {
  softwareName: string | undefined
  softwareType: string | undefined
  status: number | undefined
  sort: Array<string>
}
export interface SoftwarePageQuery extends SoftwareQuery, PageQuery {}

/** @desc 查询软件版本列表 */
export function listSoftware(query: SoftwarePageQuery) {
  return http.get<PageRes<SoftwareResp[]>>(`${BASE_URL}`, query)
}

/** @desc 查询软件版本详情 */
export function getSoftware(id: string) {
  return http.get<SoftwareDetailResp>(`${BASE_URL}/${id}`)
}

/** @desc 新增软件版本 */
export function addSoftware(data: any) {
  return http.post(`${BASE_URL}`, data)
}

/** @desc 修改软件版本 */
export function updateSoftware(data: any, id: string) {
  return http.put(`${BASE_URL}/${id}`, data)
}

/** @desc 删除软件版本 */
export function deleteSoftware(id: string) {
  return http.del(`${BASE_URL}/${id}`)
}
